package com.jackrain.nea.omslocal.util;/**
 * Created by Administrator on 2017/3/29.
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Description: 校验字符串是否是 date 类型
 * Created with IntelliJ IDEA.
 * User: cs
 * Date: 2017/3/29
 * Time: 18:37
 */
@Component
@Slf4j
public class RegexDateUtil {

    /**
     * 校验是否是时间
     *
     * @param str
     * @return
     */
    public boolean regexDate(String str){

        String regex = "(\\p{Nd}++)\\Q-\\E(\\p{Nd}++)\\Q-\\E(\\p{Nd}++)\\Q \\E(\\p{Nd}++)\\Q:\\E(\\p{Nd}++)\\Q:\\E(\\p{Nd}++)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        // 字符串是否与正则表达式相匹配
        return matcher.matches();
    }

}
